<!DOCTYPE html>
<html>
<head>
    <title>Car Practice</title>
</head>
<body>
    <form method="POST">
        {{frm.csrf_token()}} {# csrf token #}
        {{frm.username.label}}{{frm.username}}
        {{frm.carName.label}}{{frm.carName}}
        {{frm.carNo.label}}{{frm.carNo}}
        {{frm.submit}}
        {% for f,m in frm.errors.items() %}
            {{f}} -> {{m}} <br>
        {% else %}
            {% for m in get_flashed_messages() %}
                {{m}}
            {% endfor %}
        {% endfor %}
    </form>
    <hr>
    <ul>
        {% for p in drivers %}
            {# url_for可以根据函数名找到对应的uri #}
            <li>{{p.name}}<a href="{{ url_for('delDriver', id=p.id) }}">del</a></li>
            <ul>
                {% for c in p.cars %}                
                    <li>{{c.name}}-{{c.no}}<a href="{{ url_for('delCar', id=c.id) }}">del</a></li>
                {% else %}
                    <li>no car</li>
                {% endfor %}
            </ul>
        {% else %}
            <li>no driver</li>
        {% endfor %}
    </ul>
</body>
</html>